jQuery.support.cors = true;
var fitech = {
	operator : "",
	path : "",
	menu : function(o) {
		var menu = Object.create(Menu);
		menu.divId = o.divId;
		if (o != null && !isEmpty(o.divClass)) {
			menu.divClass = o.divClass;
		}
		menu.data = o.data;
		menu.state = o.state;
		menu.url = o.url;
		menu.error = o.error;
		menu.initMenu(o);
	},

	menu5 : function(o) {
		var menu5 = Object.create(Menu5);
		menu5.divId = o.divId;
		if (o != null && !isEmpty(o.divClass)) {
			menu5.divClass = o.divClass;
		}
		menu5.data = o.data;
		menu5.state = o.state;
		menu5.url = o.url;
		menu5.error = o.error;
		menu5.initMenu(o);
	},

	menu2 : function(o) {
		var menu2 = Object.create(Menu2);
		menu2.divId = o.divId;
		if (o != null && !isEmpty(o.divClass)) {
			menu2.divClass = o.divClass;
		}
		menu2.data = o.data;
		menu2.state = o.state;
		menu2.url = o.url;
		menu2.error = o.error;
		menu2.initMenu(o);
	},

	menu6 : function(o) {
		var menu6 = Object.create(Menu6);
		menu6.divId = o.divId;
		if (o != null && !isEmpty(o.divClass)) {
			menu6.divClass = o.divClass;
		}
		menu6.data = o.data;
		menu6.state = o.state;
		menu6.url = o.url;
		menu6.error = o.error;
		menu6.initMenu(o);
	},

	activeMenu : function(o) {
		var contentId = o.contentId;
		var menuData = o.data;
		$.each(menuData, function(i) {
			$("#" + menuData[i].menuId).removeClass("noRight");
			if (menuData[i].menuParId != '0') {
				$("#" + menuData[i].menuId + " a").attr(
						"href",
						"javascript:changeUrl('" + menuData[i].menuUrl + "','"
								+ contentId + "','" + menuData[i].menuName
								+ "','" + menuData[i].business + "','"
								+ menuData[i].menuId + "')");
			}
		});
	},
	activeMenu1 : function(o) {
		var contentId = o.contentId;
		var menuData = o.data;
		$.each(menuData, function(i) {
			$("#topNav2 #" + menuData[i].menuId).removeClass("noRight");
			if (menuData[i].menuParId != '0') {
				$("#topNav2 #" + menuData[i].menuId + " a").attr(
						"href",
						"javascript:changeUrl('" + menuData[i].menuUrl + "','"
								+ contentId + "','" + menuData[i].menuName
								+ "','" + menuData[i].business + "','"
								+ menuData[i].menuId + "')");
			}
		});
	},
	get : function(o) {
		showMask();

		o.url = this.path + o.url;
		var ajax = Object.create(Ajax);
		return ajax.doAjax(o, "GET", this.operator);
	},
	put : function(o) {
		showMask();
		o.url = this.path + o.url;
		var ajax = Object.create(Ajax);
		return ajax.doAjax(o, "PUT", this.operator);
	},
	post : function(o) {
		showMask();
		o.url = this.path + o.url;
		var ajax = Object.create(Ajax);
		return ajax.doAjax(o, "POST", this.operator);
	},
	del : function(o) {
		showMask();
		o.url = this.path + o.url;
		var ajax = Object.create(Ajax);
		return ajax.doAjax(o, "DELETE", this.operator);
	},
	alertInfo : function(state, message) {
		_newalertInfo(state, message);
	},
	destroyDatatables : function(tableId) {
		if ($.fn.dataTable.isDataTable('#' + tableId)) {
			var instInfoTable = $('#' + tableId).DataTable();
			instInfoTable.destroy();
			instInfoTable = null;
		}
		$("#" + tableId).removeClass();
		$("#" + tableId).addClass(
				"table table-striped table-bordered table-hover");
	},
	fadeOutError : function(id) {
		fadeOutError(id);
	},
	saveLog : function(msg, menuName) {
		this.post({
			url : '/sysLog',
			data : {
				userId : fitech.operator.userId,
				userName : fitech.operator.userName,
				logContent : msg,
				operationModule : menuName
			}
		});
	},
	isNotStrEmpty : function(str) {
		if (str != null && str != undefined && str != '') {
			return true;
		}
		return false;
	}
};

var Ajax = {
	url : "",
	type : "",
	async : false,
	data : {},
	dataType : "",
	error : function(jqXHR) {
		if(jqXHR != undefined && jqXHR.responseText == 'expire'){
			_alertInfo('warining',
			'哎呀，当前用户已离线~！<a href="#" onclick="errorReload()">请重新登录</a>');
		}else{
			_alertInfo('warining',
			'哎呀，系统出了点小问题~！<a href="#" onclick="errorReload()">重新登录</a>');
		}
		hideMask();
	},
	doAjax : function(o, type, operator) {
		var _result;

		this.url = o.url;

		if (o != null && !isEmpty(o.async)) {
			this.async = o.async;
		}
		if (o != null && !isEmpty(o.error)) {
			ajax.error = o.error;
		}

		if (!isEmpty(o.data)) {
			this.data = o.data;
		}

		if (type == "POST") {
			this.type = "POST";
		} else if (type == "GET") {
			this.type = "GET";
		} else if (type == "PUT") {
			this.type = "POST";
			this.data._method = "PUT";
		} else if (type == "DELETE") {
			this.type = "POST";
			this.data._method = "DELETE";
		}

		this.data.token = isEmpty(operator) ? "" : operator.token;
		this.data.tokenUserId = isEmpty(operator) ? "" : operator.userId;

		var request = $.ajax({
			url : this.url,
			type : this.type,
			async : this.async,
			data : this.data,
			dataType : this.dataType,
			success : function(data) {
				_result = data;
				if (o != null && !isEmpty(o.success)) {
					o.success(_result);
				}
				// setTimeout(
				// function(){
				hideMask();
				// },10000);
			},error:function(jqXHR) {
				Ajax.error(jqXHR);
				}
		});
		return _result;
	}
};

var Menu = {
	divId : "1",
	contentId : "",
	divClass : "newMenu",
	data : {},
	state : "",
	url : "",
	initMenu : function() {
		$("#" + this.divId).addClass(this.divClass);
		var html = createMenu(this.data, this.state);
		$("#" + this.divId).html(html);
		$("#" + this.divId).children("ul").children("li").children("p")
				.addClass("active2");
		$("#" + this.divId)
				.children("ul")
				.attr(
						"style",
						"width: 111%;height: 100%; background-color: #364860;overflow-y:scroll;overflow-x:hidden;max-height: 85%;");
		// var arr = new Array("fa fa-indent", "", "fa fa-sitemap", "",
		// "fa fa-user-plus", "", "fa fa-users", "", "fa fa-book");
		$("#" + this.divId).children("ul").children("li").children("ul")
				.children("li").children("p").attr("class", "son_menu");
		// for (var i = 0; i < arr.length * 2; i = i + 2) {
		// $("." + this.divClass + " ul li").children("p").children(
		// "i:eq(" + i + ")").attr("class", arr[i]);
		// }
		$("#" + this.divId).children("ul").children("li").children("p").bind(
				"click", function() {
					$(this).parent("li").children("ul").slideToggle(300);
				});
		$("#" + this.divId).children("ul").children("li").children("ul")
				.children("li").bind("click", function() {
				});

		// $("." + this.divClass + " ul li").addClass('noRight');
		$("." + this.divClass + " ul li a").removeAttr("href");
	},

};

var Menu5 = {
	divId : "5",
	contentId : "",
	divClass : "newMenu5",
	data : {},
	state : "",
	url : "",
	initMenu : function() {
		$("#" + this.divId).addClass(this.divClass);
		var html = "<div style=\"color: #333; cursor: pointer; overflow: hidden;\""
				+ "id=\"xtgl\">"
				+ "<i class=\"fa fa-th\" id=\"menuTitleIcon\"></i>&nbsp;&nbsp;&nbsp;&nbsp;<label id=\"menuTitle\"></label>"
				+ "<i class=\"fa fa-list-ul\" style=\"font-size: 14px;line-height:38px;\"></i>"
				+ "</div>" + createMenu5(this.data, this.state);
		$("#" + this.divId).html(html);
		$("#" + this.divId).children("ul").children("li").children("p")
				.addClass("active2");
		$("#" + this.divId)
				.children("ul")
				.attr("style",
						"width: 111%;height: 100%;overflow-y:scroll;overflow-x:hidden;max-height: 88%;");
		$("#" + this.divId).children("ul").children("li").children("ul")
				.children("li").children("p").attr("class", "son_menu");
		$("#" + this.divId).children("ul").children("li").children("p")
				.bind(
						"click",
						function() {
							// $(this).parent("li").children("ul").slideToggle(300);
							if ($(this).parent("li").children("ul").css(
									"display") == "block") {
								$(this).parent("li").children("ul")
										.slideUp(300);
								$(this).parent("li").children("p").children(
										"i:eq(1)").removeClass();
								$(this).parent("li").children("p").children(
										"i:eq(1)").addClass("fa fa-plus");
							} else {
								$(this).parent("li").children("ul").slideDown(
										300);
								$(this).parent("li").children("p").children(
										"i:eq(1)").removeClass();
								$(this).parent("li").children("p").children(
										"i:eq(1)").addClass("fa fa-minus");
							}
						});
		$("#" + this.divId).children("ul").children("li").children("ul")
				.children("li").bind("click", function() {
				});
		$("." + this.divClass + " ul li a").removeAttr("href");
	},

};

var Menu2 = {
	divId : "2",
	contentId : "",
	divClass : "newMenu2",
	data : {},
	state : "",
	url : "",
	initMenu : function() {
		$("#" + this.divId).addClass(this.divClass);
		var html = "<div style=\"color: #DBE3EF; background-color: #202f46; cursor: pointer; overflow: hidden;\""
				+ "id=\"xtgl2\">"
				+ "<i class=\"fa fa-arrow-circle-o-right\" style=\"font-size: 20px\"></i>"
				+ "</div>" + createMenu2(this.data, this.state);
		$("#" + this.divId).html(html);
		$("#" + this.divId).children("ul").children("li").children("p")
				.addClass("active2");
		$("#" + this.divId).children("ul").attr("style",
				"width: 100%;height: 100%; background-color: #364860;");
		// var arr = new Array("fa fa-indent", "fa fa-sitemap", "fa
		// fa-user-plus",
		// "fa fa-users", "fa fa-book");
		$("#" + this.divId).children("ul").children("li").children("ul")
				.children("li").children("p").attr("class", "son_menu");
		// for (var i = 0; i < arr.length; i++) {
		// $("." + this.divClass + " ul li").children("p").children(
		// "i:eq(" + i + ")").attr("class", arr[i]);
		// }
		// $("#" + this.divId).children("ul").children("li").children("p").bind(
		// "click", function() {
		// $(this).parent("li").children("ul").slideToggle(300);
		// });
		$("." + this.divClass + " ul li a").removeAttr("href");
	},

};

var Menu6 = {
	divId : "6",
	contentId : "",
	divClass : "newMenu6",
	data : {},
	state : "",
	url : "",
	initMenu : function() {
		$("#" + this.divId).addClass(this.divClass);
		var html = "<div style=\"color:#333; cursor: pointer; overflow: hidden;\""
				+ "id=\"xtgl2\">"
				+ "<i class=\"fa fa-list-ul\" style=\"font-size: 14px;line-height:38px;\"></i>"
				+ "</div>" + createMenu6(this.data, this.state);
		$("#" + this.divId).html(html);
		$("#" + this.divId).children("ul").children("li").children("p")
				.addClass("active2");
		$("#" + this.divId).children("ul").attr("style",
				"width: 100%;height: 100%;");
		$("#" + this.divId).children("ul").children("li").children("ul")
				.children("li").children("p").attr("class", "son_menu");
		$("." + this.divClass + " ul li a").removeAttr("href");
	},

};

function createMenu(data, state) {
	if (typeof data == "undefine" || data.length == 0) {
		return "";
	}

	var html = "<ul>";
	$.each(data, function(index, value) {
		html += "<li id=\"" + value.menuId + "\" style=\"cursor: pointer;\"";
		if (state == "all") {
			html += " class=\"active\" ";
		} else if (state == "none") {
			html += " ";
		} else {
			if (!isEmpty(value.state) && value.state == "active") {
				html += " class=\"active\" ";
			} else {
				html += " ";
			}
		}
		if (state != "all")
			html += "><p><a href='#' style=\"text-decoration: none;\">"
					+ value.menuName + "</a></p>";
		else
			html += "><p><i class='" + value.menuClass + "'></i>"
					+ "&nbsp;&nbsp;" + value.menuName + "&nbsp;&nbsp;"
					+ "<i class=\"fa fa-angle-down\"></i></p>";
		html += createMenu(value.children);
		html + "</li>";
	});
	html += "</ul>";
	return html;
}

function createMenu5(data, state) {
	if (typeof data == "undefine" || data.length == 0) {
		return "";
	}

	var html = "<ul>";
	$
			.each(
					data,
					function(index, value) {
						html += "<li id=\"" + value.menuId
								+ "\" style=\"cursor: pointer;\"";
						if (state == "all") {
							html += " class=\"active\" ";
						} else if (state == "none") {
							html += " ";
						} else {
							if (!isEmpty(value.state)
									&& value.state == "active") {
								html += " class=\"active\" ";
							} else {
								html += " ";
							}
						}
						if (state != "all")
							html += "><p><i class=\"fa fa-share\"></i>&nbsp;&nbsp;&nbsp;<a href='#' style=\"text-decoration: none;\">"
									+ value.menuName + "</a></p>";
						else
							html += "><p><i class='"
									+ value.menuClass
									+ "'></i>"
									+ "&nbsp;&nbsp;&nbsp;"
									+ value.menuName
									+ "&nbsp;&nbsp;"
									+ "<i class=\"fa fa-minus\" style=\"line-height:35px;\"></i></p>";
						html += createMenu5(value.children);
						html + "</li>";
					});
	html += "</ul>";
	return html;
}

function createMenu2(data, state) {
	if (typeof data == "undefine" || data.length == 0) {
		return "";
	}

	var html = "<ul>";
	$.each(data, function(index, value) {
		html += "<li id=\"" + value.menuId + "\" style=\"margin-bottom:1px\"";
		if (state == "all") {
			html += " class=\"active\" ";
		} else if (state == "none") {
			html += " ";
		} else {
			if (!isEmpty(value.state) && value.state == "active") {
				html += " class=\"active\" ";
			} else {
				html += " ";
			}
		}
		if (state != "all")
			html += "><p><a href='#' style=\"text-decoration: none;\">"
					+ "</a></p>";
		else
			html += "><p><i class='" + value.menuClass + "'></i>" + "</p>";
		html += createMenu2(value.children);
		html + "</li>";
	});
	html += "</ul>";
	return html;
}

function createMenu6(data, state) {
	if (typeof data == "undefine" || data.length == 0) {
		return "";
	}

	var html = "<ul>";
	$.each(data, function(index, value) {
		html += "<li id=\"" + value.menuId + "\" style=\"margin-bottom:1px\"";
		if (state == "all") {
			html += " class=\"active\" ";
		} else if (state == "none") {
			html += " ";
		} else {
			if (!isEmpty(value.state) && value.state == "active") {
				html += " class=\"active\" ";
			} else {
				html += " ";
			}
		}
		if (state != "all")
			html += "><p><a href='#' style=\"text-decoration: none;\">"
					+ "</a></p>";
		else
			html += "><p><i class='" + value.menuClass + "'></i>" + "</p>";
		html += createMenu6(value.children);
		html + "</li>";
	});
	html += "</ul>";
	return html;
}

function isEmpty(o) {
	if (typeof o == 'undefine' || o == null || o == "") {
		return true;
	} else {
		return false;
	}
}

function _alertInfo(state, message) {
	var alertHtml = '<div class="modal fade mtop" id="alertInfo" style="z-index: 9999">'
			+ '<div id="alertInfoStyle" class="alert alert-dismissable" role="alert" style="margin:20% 27%;font-size:18px">'
			+ '<button type="button" class="close" data-dismiss="modal">'
			+ '<span aria-hidden="true">&times;</span><span class="sr-only">Close</span>'
			+ '</button>'
			+ '<div id="alertInfoMsg"></div>'
			+ '</div>'
			+ '</div>';
	$("#content").append(alertHtml);
	if (state == 'success') {
		$("#alertInfoStyle").attr("class",
				"alert alert-dismissable alert-success");
	} else {
		$("#alertInfoStyle").attr("class",
				"alert alert-dismissable alert-danger");
	}
	$("#alertInfoMsg").html(message);

	$("#alertInfo").modal({
		backdrop : 'static',
		keyboard : false
	});
}

function _newalertInfo(state, message) {
	var alertHtml = '<div class="modal fade mtop" id="alertInfo1" style="z-index:9999;">'
			+ '<div id="alertInfoStyle1" class="alert alert-dismissable" role="alert" style="margin:20% 27%;font-size:18px">'
			+ '<button type="button" class="close" data-dismiss="modal">'
			+ '<span aria-hidden="true">&times;</span><span class="sr-only">Close</span>'
			+ '</button>'
			+ '<div id="alertInfoMsg1"></div>'
			+ '</div>'
			+ '</div>';
	$("#content").append(alertHtml);
	$("#alertInfoMsg1").html(message);
	if (state == 'success') {
		$("#alertInfoStyle1").attr("class",
				"alert alert-dismissable alert-success");
		$("#alertInfo1").modal();
	} else {
		$("#alertInfoStyle1").attr("class",
				"alert alert-dismissable alert-danger");
		$("#alertInfo1").modal({
			backdrop : 'static',
			keyboard : false
		});
	}

	$(".modal-backdrop:last").addClass("lastfade");
}

function fadeOutError(id) {
	$("#" + id).html("");
}
/*
 * function _newalertInfo(state, message) { var alertHtml = '<div class="modal
 * fade mtop" id="alertInfo1" style="z-index:9999;width:60%;top:14%;left:29%;">' + '<div
 * id="alertInfoStyle1" class="alert alert-dismissable" role="alert">' + '<button
 * type="button" class="close" data-dismiss="modal">' + '<span
 * aria-hidden="true">&times;</span><span class="sr-only">Close</span>' + '</button>' + '<div
 * id="alertInfoMsg1"></div>' + '</div>' + '</div>';
 * $("#content").append(alertHtml); if (state == 'success') {
 * $("#alertInfoStyle1").attr("class", "alert alert-dismissable alert-success"); }
 * else if (state == 'warining') { $("#alertInfoStyle1").attr("class", "alert
 * alert-dismissable alert-warning"); } $("#alertInfoMsg1").html(message);
 * $("#alertInfo1").modal();
 * $(".modal-backdrop:last").removeClass("modal-backdrop");
 * $("#alertInfoStyle1").fadeOut(2500); setTimeout(function() {
 * $("#alertInfo1").remove(); }, 2500); }
 */

function bindinputsearch(inuptid, datableobj, notLikeId) {
	// 回车提交搜索
	$(window).keydown(function(event) {
		if (event.keyCode == 13) {
			event.preventDefault();
			return false;
		}
	});
	var searchbox = $('#' + inuptid);
	searchbox.unbind();
	searchbox.bind('keyup', function(e) {
		if (e.keyCode == 13) {
			// datableobj.column($(this).parents('div').attr('data-column'))
			// .search(this.value).draw();
			searchbox.each(function(i) {
				var filterId = $(this).attr("id");
				filterId = filterId.split("_");
				var filterValue = $(this).val();
				filterValue = filterValue.replace(/\s+/g, '');
				if (filterId[2] == notLikeId) {
					var val = $.fn.dataTable.util.escapeRegex(filterValue);
					datableobj.column(filterId[2]).search(
							val ? '^' + val + '$' : '', true, false).draw();
				} else {
					datableobj.column(filterId[2]).search(filterValue, false,
							false).draw();
				}
			});
			if ($("#moreSearchItems").css("display") == "block") {
				$("#moreSearchItems").slideUp();
			}
		}
	});

	var uitool = '';
	searchbox.on("mousedown", function() {
		uitool = 'mouse';
	});
	searchbox.on("keydown", function() {
		uitool = 'keyboard';
	});

	// Reset the search if the "x" is pressed in the filter box
	searchbox.bind('input', function() {
		if ((this.value == "") && (datableobj.search() != '')
				&& (uitool == 'mouse')) {
			// datableobj.column($(this).parents('div').attr('data-column'))
			// .search('').draw();
			searchbox.each(function(i) {
				var filterId = $(this).attr("id");
				filterId = filterId.split("_");
				var filterValue = $(this).val();
				filterValue = filterValue.replace(/\s+/g, '');
				if (filterId[2] == notLikeId) {
					var val = $.fn.dataTable.util.escapeRegex(filterValue);
					datableobj.column(filterId[2]).search(
							val ? '^' + val + '$' : '', true, false).draw();
				} else {
					datableobj.column(filterId[2]).search(filterValue, false,
							false).draw();
				}
			});
			if ($("#moreSearchItems").css("display") == "block") {
				$("#moreSearchItems").slideUp();
			}
			return;
		}

	});
}

function showMask() {
	$("#loading").css("height", $(document).height());
	$("#loading").css("width", $(document).width());
	$("#loading").css("display", "block");
	// alert(2);
}
function hideMask() {
	// setTimeout(function() {
	// $("#loading").css("display","none"); }, 2000);
	$("#loading").css("display", "none");
}

function getToday() {
	var d = new Date();
	var year = d.getFullYear();
	var month = d.getMonth() + 1; // 记得当前月要+1
	month = month < 10 ? ('0' + month) : month;
	var dt = d.getDate();
	dt = dt < 10 ? ('0' + dt) : dt;
	var today = year + "-" + month + "-" + dt;
	return today;
}

lengthMenu = [ 10 ];

var sjblContent = "xtglContent";

function filterGlobal(divId, datatableId, notLikeId) {
	$("#" + divId + " input").each(
			function(i) {
				var filterId = $(this).attr("id");
				// console.log(filterId);
				if (filterId.indexOf('_') != -1) {
					filterId = filterId.split("_");
				}
				var filterValue = $(this).val();
				if (filterValue == "全部") {
					filterValue = "";
				}
				// console.log(filterValue);
				filterValue = filterValue.replace(/\s+/g, '');
				if (filterId[2] == notLikeId) {
					var val = $.fn.dataTable.util.escapeRegex(filterValue);
					$('#' + datatableId).DataTable().column(filterId[2])
							.search(val ? '^' + val + '$' : '', true, false)
							.draw();
				} else {
					$('#' + datatableId).DataTable().column(filterId[2])
							.search(filterValue, false, false).draw();
				}
			});
}
// 多个条件精确查询
function filterGlobal_new(divId, datatableId, notLikeIdArray) {
	$("#" + divId + " input").each(
			function(i) {
				var flag = false;
				var filterId = $(this).attr("id");
				if (filterId.indexOf('_filter_') != -1) {

					filterId = filterId.split("_");
					var filterValue = $(this).val();
					if (filterValue == "全部") {
						filterValue = "";
					}
					filterValue = filterValue.replace(/\s+/g, '');
					// 需要精确查询的列
					$.each(notLikeIdArray, function(i) {
						if (filterId[2] == notLikeIdArray[i]) {
							var val = $.fn.dataTable.util
									.escapeRegex(filterValue);
							filterValue = val ? '^' + val + '$' : '';
							flag = true;
						}
					});

					$('#' + datatableId).DataTable().column(filterId[2])
							.search(filterValue, flag, false).draw();

				}
			});
	$('#' + datatableId).DataTable().draw();
}

// 多个条件精确查询，带区间查询
function filterGlobal_new2(divId, datatableId, startId, endId, timeColumn) {
	$("#" + divId + " input").each(
			function(i) {
				var filterId = $(this).attr("id");
				filterId = filterId.split("_");
				var filterValue = $(this).val();
				if (filterValue == "全部") {
					filterValue = "";
				}
				filterValue = filterValue.replace(/\s+/g, '');
				if (filterId[2] != undefined) {
					$('#' + datatableId).DataTable().column(filterId[2])
							.search(filterValue, false, false).draw();
				}
			});
	$.fn.dataTable.ext.search.push(function(settings, data, dataIndex) {
		var min = parseInt($("#" + startId).val(), 10);
		var max = parseInt($("#" + endId).val(), 10);
		var age = parseFloat(data[timeColumn]) || 0; // use data for the age
		// column
		if ((isNaN(min) && isNaN(max)) || (isNaN(min) && age <= max)
				|| (min <= age && isNaN(max)) || (min <= age && age <= max)) {
			return true;
		}
		return false;
	});
	$("#" + datatableId).DataTable().draw();
}

// 多个条件精确查询，多个区间查询
function filterGlobal_new3(divId, datatableId, startId, endId, timeColumn,
		startIds, endIds, timeColumns) {
	$("#" + divId + " input").each(
			function(i) {
				var filterId = $(this).attr("id");
				filterId = filterId.split("_");
				var filterValue = $(this).val();
				if (filterValue == "全部") {
					filterValue = "";
				}
				filterValue = filterValue.replace(/\s+/g, '');
				if (filterId[2] != undefined) {
					$('#' + datatableId).DataTable().column(filterId[2])
							.search(filterValue, false, false).draw();
				}
			});
	$.fn.dataTable.ext.search.push(function(settings, data, dataIndex) {
		var min = parseInt($("#" + startId).val(), 10);
		var max = parseInt($("#" + endId).val(), 10);
		var age = parseFloat(data[timeColumn]) || 0; // use data for the age
		// column
		if ((isNaN(min) && isNaN(max)) || (isNaN(min) && age <= max)
				|| (min <= age && isNaN(max)) || (min <= age && age <= max)) {
			return true;
		}
		return false;
	});
	$.fn.dataTable.ext.search.push(function(settings, data, dataIndex) {
		var min = parseInt($("#" + startIds).val(), 10);
		var max = parseInt($("#" + endIds).val(), 10);
		var age = parseFloat(data[timeColumns]) || 0; // use data for the age
		// column
		if ((isNaN(min) && isNaN(max)) || (isNaN(min) && age <= max)
				|| (min <= age && isNaN(max)) || (min <= age && age <= max)) {
			return true;
		}
		return false;
	});
	$("#" + datatableId).DataTable().draw();
}

function searchAreaDown() {
	$("#moreSearchItems").slideDown();
	$("#moreSearch i").removeClass();
	$("#moreSearch i").addClass("fa fa-caret-up");
}
function searchAreaUp() {
	$("#moreSearchItems").slideUp();
	$("#moreSearch i").removeClass();
	$("#moreSearch i").addClass("fa fa-caret-down");
}

// 把data降一个纬度，方便后台处理
function planify(data) {
	for (var i = 0; i < data.columns.length; i++) {
		column = data.columns[i];
		column.searchRegex = column.search.regex;
		column.searchValue = column.search.value;
		delete (column.search);
	}
}

function isValidDate(dateString) {
	// First check for the pattern
	var regex_date = /^\d{4}\-\d{1,2}\-\d{1,2}$/;

	if (!regex_date.test(dateString)) {
		return false;
	}

	// Parse the date parts to integers
	var parts = dateString.split("-");
	var day = parseInt(parts[2], 10);
	var month = parseInt(parts[1], 10);
	var year = parseInt(parts[0], 10);

	// Check the ranges of month and year
	if (year < 1000 || year > 3000 || month == 0 || month > 12) {
		return false;
	}

	var monthLength = [ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 ];

	// Adjust for leap years
	if (year % 400 == 0 || (year % 100 != 0 && year % 4 == 0)) {
		monthLength[1] = 29;
	}

	// Check the range of the day
	return day > 0 && day <= monthLength[month - 1];
}
// String2Date
function getDate(strDate) {
	var date = eval('new Date('
			+ strDate.replace(/\d+(?=-[^-]+$)/, function(a) {
				return parseInt(a, 10) - 1;
			}).match(/\d+/g) + ')');
	return date;
}

// Date2String
function DateHandle(time) {
	var objDate = eval('new ' + eval('/Date(' + time + ')/').source)
	var year = objDate.getFullYear(); // 四位数字年
	var month = objDate.getMonth() + 1; // getMonth()返回的月份是从0开始的，还要加1
	if (month > 0 && month < 10) {
		month = "0" + month;
	}
	var date = objDate.getDate();
	if (date > 0 && date < 10) {
		date = "0" + date;
	}
	var hours = objDate.getHours();
	if (hours >= 0 && hours < 10) {
		hours = "0" + hours;
	}
	var minutes = objDate.getMinutes();
	if (minutes >= 0 && minutes < 10) {
		minutes = "0" + minutes;
	}
	var seconds = objDate.getSeconds();
	if (seconds >= 0 && seconds < 10) {
		seconds = "0" + seconds;
	}
	var date = year + "-" + month + "-" + date + " " + hours + ":" + minutes
			+ ":" + seconds;
	// var date = year+"-"+month+"-"+date;
	return date;
}

function errorReload() {
	errorLogout();
	window.location.replace('');
}
function errorLogout() {
	fitech.operator = null;
	$.sessionStorage('operator', fitech.operator);
}